﻿Imports System.Data.OleDb

Public Class VideoGal
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub btnUploadVideo_Click(sender As Object, e As EventArgs) Handles btnUploadVideo.Click

        ' ImageIpload is the name of the upload box field. 

        If tbxvideoID.Text = "" And txbTitle.Text = "" Then
            MsgBox("ERROR - You have done one of the following things WRONG! Please check video code ID or and an Title for the video")
        Else

            Dim sql As String = "INSERT INTO  Videos (VideoLink,VideoTitle,VideoDescription,DateUploaded,TimeUploaded,MemberIDFK) VALUES (@f1,@f2,@f3,@f4,@f5)"
            Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("MercedesConnectionString").ConnectionString)
            Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)

            cmd.Parameters.AddWithValue("@f1", tbxvideoID.Text)
            cmd.Parameters.AddWithValue("@f2", txbTitle.Text)
            cmd.Parameters.AddWithValue("@f3", tbxDescription.Text)
            cmd.Parameters.AddWithValue("@f4", Now.Date.ToString("dd/MM/yyyy"))
            cmd.Parameters.AddWithValue("@f5", DateTime.Now.ToString("t"))
            cmd.Parameters.AddWithValue("@f6", Membership.GetUser(User.Identity.Name).ProviderUserKey)


            conn.Open()
            cmd.ExecuteNonQuery()
            conn.Close()
            cmd.Dispose()

            Response.Redirect("VideoGal.aspx")
        End If
    End Sub
End Class